package cn.edu.scau.sec.caixiaoqing.adapter;

import java.util.Calendar;

public class ObjectLineAdapter implements Target{

    private Adaptee adaptee = null;

    public ObjectLineAdapter(Adaptee adaptee){
        this.adaptee = adaptee;
    }

    @Override
    public void printDate(String calendarString) {

        Calendar calendar = Calendar.getInstance();

        String[] split = calendarString.split("\\-");

        int year = Integer.parseInt(split[0]);
        int month = Integer.parseInt(split[1]);
        int day = Integer.parseInt(split[2]);

        calendar.set(year, month - 1, day);

        System.out.println("对象适配器：");
        adaptee.printCalendar(calendar);
    }
}
